﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace ProjBackEnd.Areas.ExtPub.Models
{
    /// <summary>
    /// 微信接口基础应答
    /// </summary>
    public class ExtWxBaseResp
    {
        /// <summary>
        /// 错误码：-1-系统繁忙，此时请开发者稍候再试；0-请求成功；40029-code 无效；45011-频率限制，每个用户每分钟100次；
        /// </summary>
        public int errcode { get; set; } = 0;
        /// <summary>
        /// 错误信息
        /// </summary>
        public string errmsg { get; set; } = "";
    }

    /// <summary>
    /// 微信auth.code2Session接口应答
    /// </summary>
    public class ExtWxRespCode2Session: ExtWxBaseResp
    {
        /// <summary>
        /// 用户唯一标识
        /// </summary>
        public string openid { get; set; } = "";
        /// <summary>
        /// 会话密钥
        /// </summary>
        public string session_key { get; set; } = "";
        /// <summary>
        /// 用户在开放平台的唯一标识符，在满足 UnionID 下发条件的情况下会返回
        /// </summary>
        public string unionid { get; set; } = "";
    }

    public class ExtWxRespSendMsg: ExtWxBaseResp
    {
        public long msgid { get; set; }
    }

    public class ExtWxReqSendMessage
    {
        public string touser { get; set; } = "";
        public string template_id { get; set; } = "";
        public string url { get; set; } = "";
        public ExtWxSendMsgMiniApp miniprogram { get; set; } = new ExtWxSendMsgMiniApp();
        public ExtWxSendMsgData data { get; set; } = new ExtWxSendMsgData();
    }

    public class ExtWxSendMsgMiniApp
    {
        public string appid { get; set; } = "";
        public string pagepath { get; set; } = "";
    }
    public class ExtWxSendMsgData
    {
        [Required]
        public ExtWxSendMsgDataCore first { get; set; }
        public ExtWxSendMsgDataCore keyword1 { get; set; }
        public ExtWxSendMsgDataCore keyword2 { get; set; }
        public ExtWxSendMsgDataCore keyword3 { get; set; }
        public ExtWxSendMsgDataCore keyword4 { get; set; }
        public ExtWxSendMsgDataCore keyword5 { get; set; }
        public ExtWxSendMsgDataCore remark { get; set; }
    }

    public class ExtWxSendMsgDataCore
    {
        public string value { get; set; } = "";
        public string color { get; set; } = "";
    }

    public class ExtWxRespAccessToken: ExtWxBaseResp
    {
        public string access_token { get; set; } = "";
        public int expires_in { get; set; }
    }


    /// <summary>
    /// 微信发送至服务器的信息类
    /// </summary>
    public class ExtWxRequestXML
    {
        /// <summary>
        /// 消息接收方微信号，一般为公众平台账号微信号
        /// </summary>
        public string ToUserName { get; set; }
        /// <summary>
        /// 消息发送方微信号
        /// </summary>
        public string FromUserName { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public string CreateTime { get; set; }
        /// <summary>
        /// 信息类型 地理位置:location,文本消息:text,消息类型:image
        /// </summary>
        public string MsgType { get; set; }
        /// <summary>
        /// 信息内容
        /// </summary>
        public string Content { get; set; }
        /// <summary>
        /// 地理位置纬度
        /// </summary>
        public string Location_X { get; set; }
        /// <summary>
        /// 地理位置经度
        /// </summary>
        public string Location_Y { get; set; }
        /// <summary>
        /// 地图缩放大小
        /// </summary>
        public string Scale { get; set; }
        /// <summary>
        /// 地理位置信息
        /// </summary>
        public string Label { get; set; }
        /// <summary>
        /// 图片链接，开发者可以用HTTP GET获取
        /// </summary>
        public string PicUrl { get; set; }
        /// <summary>
        /// 事件类型，subscribe(订阅)、unsubscribe(取消订阅)、CLICK(自定义菜单点击事件) 、TEMPLATESENDJOBFINISH(模板消息回执)
        /// </summary>
        public string EventType { get; set; }
        /// <summary>
        /// 事件KEY值，与自定义菜单接口中KEY值对应
        /// </summary>
        public string EventKey { get; set; }
        /// <summary>
        /// 模板消息的ID
        /// </summary>
        public string MsgId { get; set; }
        /// <summary>
        /// 模板消息发送状态
        /// </summary>
        public string Status { get; set; }

    }

    /// <summary>
    /// 微信公众号用户详细信息
    /// </summary>
    public class ExtWxRespUserInfo : ExtWxBaseResp
    {
        public int subscribe { get; set; }
        public string openid { get; set; } = "";
        public string nickname { get; set; } = "";
        public int sex { get; set; }
        public string language { get; set; } = "";
        public string headimgurl { get; set; } = "";
        public string unionid { get; set; } = "";
        public int groupid { get; set; }
    }


}